package com.kuang.springCloud.service;

import com.kuang.springCloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

//Hystrix的服务降级
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public Dept queryById(Long id) {
                return new Dept().setDeptno(id).setDname("没有此用户信息！！！客户端提供了服务降级的信息，现在这个服务以被关闭");
            }

            @Override
            public boolean add(Dept dept) {
                return false;
            }
        };
    }
}
